# 文件异常

# Traceback (most recent call last):
#   File "D:\pythoncode\09-异常\1-异常.py", line 4, in <module>
#     f = open('test1.txt','r')
# FileNotFoundError: [Errno 2] No such file or directory: 'test1.txt'

# 除0异常
# print(1/0)
#
# Traceback (most recent call last):
#   File "D:\pythoncode\09-异常\2-异常类型.py", line 9, in <module>
#     print(1/0)
# ZeroDivisionError: division by zero

# 列表 索引越界
# list = [0,1,2,3]
# print(list[4])
#
# Traceback (most recent call last):
#   File "D:\pythoncode\09-异常\2-异常类型.py", line 18, in <module>
#     print(list[4])
# IndexError: list index out of range

# 递归错误  超出最大递归深度 （因为递归的每一个数据都需要一个存储空间）
def foo(n):
    print(n)
    foo(n-1)

foo(10)

# Traceback (most recent call last):
#   File "D:\pythoncode\09-异常\2-异常类型.py", line 29, in <module>
#     foo(10)
#   File "D:\pythoncode\09-异常\2-异常类型.py", line 27, in foo
#     foo(n-1)
#   File "D:\pythoncode\09-异常\2-异常类型.py", line 27, in foo
#     foo(n-1)
#   File "D:\pythoncode\09-异常\2-异常类型.py", line 27, in foo
#     foo(n-1)
#   [Previous line repeated 993 more times]
#   File "D:\pythoncode\09-异常\2-异常类型.py", line 26, in foo
#     print(n)
# RecursionError: maximum recursion depth exceeded while calling a Python object